<template>
    <view class="container">
        <view class="desc">
            <view> 很遗憾! </view>
            <view> 超凡云仓无法继续为您提供服务,感谢您一直以来的支持! </view>
        </view>
        <view class="wrapper">
            <view class="title"> 注销账号,需要满足以下条件 </view>
            <view>
                <view> 1.账户中相关财产已结清 </view>
                <view> 2.账户中不存在未完结的订单 </view>
                <view> 3.账户中不存在未完结的售后单 </view>
            </view>
        </view>
        <view class="btn">
            <u-button type="p" @click="confirm">同意注销</u-button>
        </view>
        <u-modal v-model="showModal" content="确认要注销账号吗?" title="" @confirm="confirmDel" show-cancel-button></u-modal>
    </view>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useUserStore } from '@/store'

const showModal = ref(false)
const userStore = useUserStore()

function confirm() {
    if (userStore.config.writeOff) {
        uni.$u.toast('请耐心等待回复,不要重复提交申请.', 2000)
        return
    }
    showModal.value = true
}
function confirmDel(){
    uni.showLoading({
        title:'请稍后...',
        mask:true
    })
    setTimeout(()=>{
        uni.hideLoading()
        uni.$u.toast('您的申请已经提交,工作人员会在1-7个工作日内给出答复.',2000)
        userStore.updateConfig({writeOff:true})
    },500)
}
</script>

<style scoped lang="scss">
.container {
    padding: 20rpx 30rpx;
    .desc {
        color: #8c8c8c;
    }
    .wrapper {
        margin-top: 20rpx;
        background-color: white;
        padding: 20rpx;
        line-height: 60rpx;
        .title {
            color: $cf-primary;
            font-size: 32rpx;
            font-weight: bold;
        }
    }
    .btn {
        position: fixed;
        bottom: 50rpx;
        width: calc(100% - 60rpx);
    }
}
</style>
